home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / rl / build-bin / mount-all-images < prev    next >
Encoding:
Text File  |  2002-06-14  |  2.1 KB  |  97 lines

  1. #!/bin/sh
  2. # mount-all-images
  3. # copyleft (c) 2000, joseph cheek, joseph@cheek.com.  released under GPL.
  4. # mount-all-images:
  5. # mount all of the (cd, floppy, ramdisk) images from a build in the
  6. # specified directory.
  7. # ex: ./mount-all-images
  8.  
  9. LANG=
  10.  
  11. MNT="/opt/redmondlinux/builds/mnt"
  12.  
  13. BUILD_NUM_FILE=/opt/redmondlinux/builds/CURRENT_BUILD
  14. BUILD_NUM=`cat $BUILD_NUM_FILE`
  15.  
  16. if [ "n$1" = "n-l" ]; then # -l
  17.   LANG="$2"
  18.   shift
  19.   shift
  20. fi
  21.  
  22. if [ -z "$LANG"  ]; then
  23.   echo -e `basename $0` \[-l lang\]: need lang \\a
  24.   exit 1
  25. fi
  26.  
  27. BUILD_BASE=/opt/redmondlinux/builds/$BUILD_NUM/$LANG
  28.  
  29.  
  30. #
  31. #
  32. # first, make the mount points, if necessary
  33.  
  34. mkdir -p "$MNT"/{{cd,install}{,_ramdisk,_ramdisk.new},scsi,pcmcia{,.new}}
  35.  
  36. # remove immutable bits
  37.  
  38. chattr -i /tmp/initrd*
  39.  
  40. # and make backup copies of the images
  41.  
  42. cp "$BUILD_BASE"/{boot/cdboot.288,floppy/*.144} /tmp
  43.  
  44. # mount ext2 files under loopback
  45.  
  46. mount -o loop "$BUILD_BASE"/boot/cdboot.288 "$MNT"/cd || 
  47.   echo -e cd mount failed\\a
  48.  
  49. mount -o loop "$BUILD_BASE"/floppy/install.144 "$MNT"/install || 
  50.   echo -e install mount failed\\a
  51.  
  52. mount -o loop "$BUILD_BASE"/floppy/scsi.144 "$MNT"/scsi ||
  53.   echo -e scsi mount failed\\a
  54.  
  55. mount -o loop "$BUILD_BASE"/floppy/pcmcia.144 "$MNT"/pcmcia || 
  56.   echo -e pcmcia mount failed\\a
  57.  
  58.  
  59. # mount initrd images from cd and install
  60.  
  61. # first, uncompress the images
  62. zcat "$MNT"/cd/initrd.gz > /tmp/initrd.cd
  63. zcat "$MNT"/install/initrd.gz > /tmp/initrd.install
  64.  
  65. # and make backups
  66. cp /tmp/initrd.cd{,.orig}
  67. cp /tmp/initrd.install{,.orig}
  68.  
  69. # and remove the originals to save space
  70. # rm "$MNT"/cd/initrd.gz
  71. # rm "$MNT"/install/initrd.gz
  72.  
  73. # then mount the originals
  74. mount -o loop /tmp/initrd.cd "$MNT"/cd_ramdisk || 
  75.   echo -e cd_ramdisk mount failed\\a
  76.  
  77. mount -o loop /tmp/initrd.install "$MNT"/install_ramdisk || 
  78.   echo -e install_ramdisk mount failed\\a
  79.  
  80. # then make them immutable so they don't [accidentally or maliciously]
  81. # get destroyed [BUG: assumes ext2 filesystem]
  82. #
  83. # fortunately [?] we can still write to the loopback-mounted filesystem
  84. # with the immutable bit set
  85. #
  86. # we must mount them before we make them immutable tho
  87. chattr +i /tmp/initrd.{cd,install}
  88.  
  89. # show mounts
  90.  
  91. df -k
  92.